package com.piggy.logi.sys.enums;

import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * 调度状态枚举
 */
@Getter
@AllArgsConstructor
public enum ScheduleStatusEnum {

    SCHEDULED(400, "调度完成", "提货"),

//    LOADED( 401, "装车完成(待发车)", "调度运单装车之后触发(若有多个调度运单，多调度运单装车后触发)"),

    PICKUPING( 402, "提货中（待发车）", "发车"),

    DEPARTED(410, "已经发车（在途中）", "到达"),

    ARRIVED(420, "已到达", "完成"),

    FINSHED(430, "已完成", "完成"),

    CANCEL_SCHEDULE(440, "取消调度", "取消调度"),

    UNSCHEDULED(0, "未调度", "未调度"),

    SCH_UNKOWN(-1, "未知状态", "未知状态"),

    ;

    private final int code;

    private final String info;

    private final String next;

    /**
     * 待发车次
     */
    public static List<Integer> getDispatchCarList0() {
        return Lists.newArrayList(SCHEDULED.code, PICKUPING.code, DEPARTED.code, ARRIVED.code, FINSHED.code, CANCEL_SCHEDULE.code);
    }

    /**
     * 在途车次
     */
    public static List<Integer> getDispatchCarList1() {
        return Lists.newArrayList(DEPARTED.code, PICKUPING.code, ARRIVED.code, FINSHED.code, CANCEL_SCHEDULE.code);
    }

    /**
     * 待发车次
     */
    public static ScheduleStatusEnum get(int code) {
        return Arrays.stream(ScheduleStatusEnum.values()).filter(t-> t.getCode()== code).findFirst().orElse(SCH_UNKOWN);
    }

}
